var jwt = require('jsonwebtoken');



// 生成token
// let token = jwt.sign(对象，加密字符串，配置项)

// let token = jwt.sign({
//     username:'altria'
// },'maimai',{
//     expiresIn:60 * 10,   //过期时间 ，单位秒
// })

// console.log('token :>> ', token);



// 校验token
let t = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFsdHJpYSIsImlhdCI6MTcyNTI2ODY1MCwiZXhwIjoxNzI1MjY5MjUwfQ.GX3GFcudfGVLMVybXAbDDuJmiz9dHMqd3Hdk4i6RozQ'

jwt.verify(t,'maimai',(error,data)=>{
    if(error){
        if(error =='TokenExpiredError: jwt expired'){
            console.log('token过期了')
        }
        console.log('出错了：',error)
        return
    }
    console.log(data)
})